﻿<Page x:Class="Halfwit.Views.OptionsPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:tw="clr-namespace:TweetSharp.Twitter.Model;assembly=TweetSharp.Twitter.ClientProfile"
    x:Name="me"
    Title="Options"
    >

    <Page.Resources>
        <Style TargetType="Button" BasedOn="{StaticResource {x:Type ButtonBase}}">
            <Setter Property="Margin" Value="4,0,0,0" />
            <Setter Property="Width" Value="65" />
        </Style>

        <DataTemplate DataType="{x:Type tw:TwitterStatus}">
            <Border
                Background="Transparent"
                BorderBrush="Silver"
                BorderThickness="0,0,0,1"
                SnapsToDevicePixels="True"
                >

                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <StackPanel 
                        Grid.Column="0"
                        Margin="4,8"
                        >
                        <Border
                            BorderBrush="DarkGray"
                            BorderThickness="1"
                            SnapsToDevicePixels="True"
                            VerticalAlignment="Top"
                            >
                            <Image Source="{Binding User.ProfileImageUrl}" 
                                Width="48" 
                                Height="48" 
                                />
                        </Border>
                    </StackPanel>

                    <StackPanel 
                        Grid.Column="1" 
                        Margin="4,4"
                        >
                        <TextBlock FontSize="{Binding DataContext.FontScale,ElementName=me,Converter={StaticResource FontScale},ConverterParameter=15}" FontWeight="Bold">
                            <Hyperlink
                                Foreground="Black"
                                TextDecorations="None"
                                >
                                <TextBlock Text="{Binding User.ScreenName}"/>
                            </Hyperlink>
                        </TextBlock>

                        <ContentControl 
                            TextBlock.FontSize="{Binding DataContext.FontScale,ElementName=me,Converter={StaticResource FontScale},ConverterParameter=13}" 
                            Margin="0,0,0,4"
                            Content="{Binding Converter={StaticResource TwitterText}}" />

                        <TextBlock 
                            FontSize="{Binding DataContext.FontScale,ElementName=me,Converter={StaticResource FontScale},ConverterParameter=11}" 
                            Text="{Binding CreatedDate,Converter={StaticResource TwitterDateTime}}" 
                            Opacity="0.6">
                        </TextBlock>
                    </StackPanel>
                </Grid>
            </Border>
        </DataTemplate>
    </Page.Resources>

    <DockPanel>
        <DockPanel DockPanel.Dock="Bottom" Margin="8,16,8,8" LastChildFill="False">
            <Button DockPanel.Dock="Right" Content="Cancel" IsCancel="True" Command="{Binding Cancel}" />
            <Button DockPanel.Dock="Right" Content="OK" IsDefault="True" Command="{Binding Save}" />
        </DockPanel>

        <Border
            DockPanel.Dock="Bottom" 
            Background="White" 
            BorderBrush="DarkGray" 
            BorderThickness="0,1,0,0" 
            SnapsToDevicePixels="True"
            Width="{Binding TweetWidth}"
            >
            <ContentControl Content="{Binding SampleTweet}" />
        </Border>

        <TextBlock DockPanel.Dock="Top" Text="Options" FontSize="16" Margin="8,2" />
        
        <ScrollViewer HorizontalContentAlignment="Center">
            <StackPanel Margin="8" MaxWidth="480">
                <GroupBox Header="Preferences" Margin="0,0,0,16" Padding="8">
                    <StackPanel>
                        <!--<CheckBox IsChecked="{Binding FocusListItems}" Margin="0,0,0,8" Content="Set keyboard focus to tweets" />-->
                        <CheckBox IsChecked="{Binding MinimizeToTray}" Margin="0,0,0,8" Content="Minimize to the taskbar notification area" />
                        <CheckBox IsChecked="{Binding OpenLinksInBrowser}" Margin="0,0,0,8" Content="Open all links in the default browser" />
                    </StackPanel>
                </GroupBox>
                
                <GroupBox Header="Updates" Margin="0,0,0,16" Padding="8">
                    <StackPanel>
                        <DockPanel>
                            <TextBlock DockPanel.Dock="Right" Text="{Binding MaxTweets,StringFormat='{}{0} tweets'}" />
                            <Label Padding="0,0,0,2" Target="{Binding ElementName=maxSlider}">Ma_ximum number of tweets to keep</Label>
                        </DockPanel>
                        <Slider x:Name="maxSlider" Margin="0,0,0,8"  IsSnapToTickEnabled="True" TickFrequency="10" Minimum="10" Maximum="1000" SmallChange="10" LargeChange="50" Value="{Binding MaxTweets}" />

                        <DockPanel>
                            <TextBlock DockPanel.Dock="Right" Text="{Binding RefreshInterval,StringFormat='{}{0} minutes'}" />
                            <Label Padding="0,0,0,2" Target="{Binding ElementName=intSlider}">Refresh _Interval</Label>
                        </DockPanel>
                        <Slider x:Name="intSlider" Margin="0,0,0,8" Minimum="1" Maximum="10"  SmallChange="1" LargeChange="2" Value="{Binding RefreshInterval}" />

                        <DockPanel>
                            <TextBlock DockPanel.Dock="Right" Text="{Binding MentionsRefreshInterval,StringFormat='{}{0} minutes'}" />
                            <Label Padding="0,0,0,2" Target="{Binding ElementName=menSlider}">_Mentions Refresh Interval</Label>
                        </DockPanel>
                        <Slider x:Name="menSlider" Margin="0,0,0,8" Minimum="2" Maximum="10"  SmallChange="1" LargeChange="2" Value="{Binding MentionsRefreshInterval}" />

                        <DockPanel>
                            <TextBlock DockPanel.Dock="Right" Text="{Binding MessagesRefreshInterval,StringFormat='{}{0} minutes'}" />
                            <Label Padding="0,0,0,2" Target="{Binding ElementName=msgSlider}">_Direct Messages Refresh Interval</Label>
                        </DockPanel>
                        <Slider x:Name="msgSlider" Margin="0,0,0,8" Minimum="2" Maximum="10"  SmallChange="1" LargeChange="2" Value="{Binding MessagesRefreshInterval}" />

                        <TextBlock Margin="0,4,0,4" TextWrapping="Wrap">Enter a search phrase here if you want to include a search as part of your Home timeline.</TextBlock>
                        <Label Padding="0,0,0,2" Target="{Binding ElementName=srchEdit}">Search _Phrase</Label>
                        <TextBox x:Name="srchEdit" Text="{Binding SearchPhrase,UpdateSourceTrigger=PropertyChanged}" MaxLength="100" />
                    </StackPanel>
                </GroupBox>

                <GroupBox Header="Display" Margin="0,0,0,16" Padding="8">
                    <StackPanel>
                        <Label Padding="0,0,0,2" Target="{Binding ElementName=scaleSlider}">Font _Size</Label>
                        <Slider x:Name="scaleSlider" Margin="0,0,0,8" Minimum="0.5" Maximum="1.5"  SmallChange="0.1" LargeChange="0.5" Value="{Binding FontScale}" />

                        <!--<Label Padding="0,0,0,2" Target="{Binding ElementName=widthSlider}">Optimum _Width (for column layout)</Label>
                        <Slider x:Name="widthSlider" Minimum="200" Maximum="480"  SmallChange="10" LargeChange="20" Value="{Binding TweetWidth}" />-->
                    </StackPanel>
                </GroupBox>
            </StackPanel>
        </ScrollViewer>
    </DockPanel>
</Page>
